<?php 
session_start();
if (!isset($_SESSION['Username'])) {
                header("location:login.php");
        }
 ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Inventory</title>
<link href="css/default.css" rel="stylesheet" type="text/css" />
<?php include('includes/path.php'); ?>

</head>

<body class="oneColFixCtrHdr">
<div id="container">
<?php include( 'includes/header.php' ); ?>
<?php include( 'includes/menu.php' ); ?>
<?php include( 'includes/status.php' ); ?>

  <div id="mainContent">
<h1>Parts Inventory</h1>

<?php 
	// This file inserts the following
	// variables: USER, PASS, DB
	include('db.php'); 

?>
 <?php
	
        $TABLE = "Parts";
        $ROW_NUMBER = 0;

        $CON = mysql_connect( $HOST, $USER, $PASS );

        if (!$CON)
          {
                  die('Could not connect: ' . mysql_error());
          }

        mysql_select_db( $DB );
        $QRY = 'SELECT * FROM ' . $TABLE;
	echo '<table style="width: 100%; border: 5px #aba groove;">';
        echo '<tr style="background-color: #D6B376;"><th style="text-align: center;">Part ID</th><th style="text-align: center; width: 75px;">Vendor ID</th><th style="width: 75px; text-align: center;">Cost</th><th style="text-align: center; width: 50px;">Qty</th><th style="text-align: center;">Description</th></tr>';
        $RESULT = mysql_query($QRY);
	while($ROW = mysql_fetch_array($RESULT))
        {
                echo '<tr style="background-color: #';
                if ( $ROW_NUMBER % 2 ){ echo 'FFF;"'; }
                else { echo 'DEDEDE;"'; }

                echo '><td style="padding-left: 5px;">' . $ROW['part_id'] . '</td><td>' . $ROW['vendor_id'] . '</td><td style="text-align: right;">$' . $ROW['cost'] .  '</td><td style="text-align: right;">' . $ROW['inventory'] . '</td><td style="text-align: right; padding-right: 5px;">' . $ROW['part_description'] . '</td></tr>';
        if ( $ROW_NUMBER % 50 == 0 && $ROW_NUMBER != 0 )
        {
                 echo '<tr style="background-color: #D6B376;"><th style="text-align: center;">Part ID</th><th style="text-align: center; width: 75px;">Vendor ID</th><th style="width: 75px; text-align: center;">Cost</th><th style="text-align: center; width: 50px;">Qty</th><th style="text-align: center;">Description</th></tr>';
        }
        $ROW_NUMBER++;
        }
        mysql_close($CON);
        echo '</table>';
?>

  <!-- end #mainContent --></div>
<?php include('includes/footer.php'); ?>
<!-- end #container --></div>
</body>
</html>
